

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;

public class SourceThread implements Runnable {
	private Socket server;
	Source r;

	SourceThread(Socket server, Source r) {
		this.r = r;
		this.server = server;
	}

	public void run() {

		try {
			// Get input from the client
			long startTime = System.nanoTime();
			DataInputStream in = new DataInputStream(server.getInputStream());

			// Now write to the client
			DataOutputStream d = new DataOutputStream(server.getOutputStream());
			long endTime = System.nanoTime() - startTime;

			d.writeUTF(r.jTextArea1.getText());

			Long recvTime = in.readLong();
			long duration = recvTime + endTime;
			//r.updateTime(duration);
			
			server.close();
		} catch (IOException ioe) {
			System.out.println("IOException on socket listen: " + ioe);
			ioe.printStackTrace();
		}
	}

}
